
do "${do}06.1_ipums_read.do"
save  "${data2}pre_84",replace



use "${data2}pre_84",clear

global sample_start 2010
* drop if year >2013
rename statefip state_fips
* merge m:1 state_fips using "${data2}state_geocodes.dta", nogen keep(3)
sort state_fips year serial
* br  year serial famid offc offto  famsize age
* keep if famsize>10

 do "${do}06.3_dem.do"


preserve

 do "${do}06.2_code_mw.do"
tempfile mw
save `mw'
restore

merge m:1 year state_fips using `mw',nogen keep(3)



preserve
* State eitc rate, pcgdp, unemprate
use  "${data2}wage_high_edu.dta",clear
merge 1:1 year state_fips using "${data2}high_edu_ur.dta", nogen keep(3)
merge 1:1 year state_fips using "${data2}hpi.dta", nogen keep(3)
merge 1:1 year state_fips using  "${data2}miscstate.dta" , nogen
* use "${data2}miscstate.dta" , clear
foreach v of varlist unemprate statepcgdp stateeitcrate statewelfareben {
  rename `v'  `v'_dube
}
* keep year state_fips gdp wage prime pop
* want controls to be the same year as reported income
* income reported in t is from t-1
* controls from t-1 should be match to t
replace year = year+1
tempfile econ
save `econ'

restore

merge m:1 year state_fips using `econ',nogen keep(3)
drop if contpov==.


save "${data1}regready_cps_ipums.dta", replace
tab year
* use "${data1}regready_cps_ipums.dta", replace
* replace dem4 = inrange(age,0,64) & inrange(dem_educ,1,2)
